/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 * Origin source from MaNGOS(GPL2).
 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
 */

#ifndef __WORLD_PACKET_H__
#define __WORLD_PACKET_H__

#include "ByteBuffer.h"

namespace PQCore
{
	// Note: opcode and size stored in platfom dependent format
	// ignore endianess until send, and converted at receive
	class WorldPacket : public ByteBuffer
	{
		public:
			// just container for later use
			WorldPacket()
				: ByteBuffer(0), _opcode(0)
			{
			}
			explicit WorldPacket(uint16 opcode, size_t res=200)
				: ByteBuffer(res), _opcode(opcode) 
			{ 
			}

			// copy constructor
			WorldPacket(const WorldPacket &packet)
				: ByteBuffer(packet), _opcode(packet.GetOpcode())
			{
			}

			void Initialize(uint16 opcode, size_t newres=200)
			{
				clear();
				_storage.reserve(newres);
				_opcode = opcode;
			}

			uint16 GetOpcode() const { return _opcode; }
			void SetOpcode(uint16 opcode) { _opcode = opcode; }

		protected:
			uint16 _opcode;
	};

}

#endif
